//
//  TSMainViewCtl.m
//  字典模型的多种使用方法
//
//  Created by 安步学车 on 2018/3/21.
//  Copyright © 2018年 aber. All rights reserved.
//

#import "TSMainViewCtl.h"
#import "TSMainModel.h"
#import "TSListModel.h"

@interface TSMainViewCtl ()

@end

@implementation TSMainViewCtl

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    //1，setValuesForKeysWithDictionary:使用方法
    [self setKeyDictionary];
    
    //2,enumerateObjectsUsingBlock:<#^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop)block#>使用方法
    [self setenumerateObjet];
}

-(void)setKeyDictionary
{
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                 @"Feng",@"name",
                                 @"19",@"age",
                                 @"西安市",@"address",
                                @"ACV",@"text",
                                 nil];
    TSMainModel *model = [[TSMainModel alloc]init];
    [model setValuesForKeysWithDictionary:dic];
    NSLog(@"%@-%@-%@",model.name,model.age,model.address);
}

-(void)setenumerateObjet
{
    NSArray *dictArray = @[
                           @{
                               @"id" : @"20",
                               @"name" : @"kids",
                               @"list" : @[
                                       @{
                                           @"age" : @"08",
                                           @"sex":@"1",
                                           @"code":@"sss"
                                           },
                                       @{
                                           @"age" : @"2",
                                           @"sex":@"2",
                                           @"code":@"aas"
                                           },
                                       ]
                               }
                           ];
    
    NSMutableArray *dataArr = [NSMutableArray array];
    [dictArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        TSMainListModel *list = [[TSMainListModel alloc]init];
        list.sid = obj[@"id"];
        list.list = obj[@"list"];
        list.name = obj[@"name"];
        [dataArr addObject:list];
        NSLog(@"%@",list.name);
    }];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
